Drop gdk init api
authorMatthias Clasen <mclasen@redhat.com>
Wed, 28 Dec 2016 21:39:22 +0000 (16:39 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 19 Jan 2017 18:21:12 +0000 (13:21 -0500)
Supporting separately initialized gdk is just not worth it.

gdk/gdk.c
gdk/gdkmain.h

index d861bc4a39685435345e18054c9a103d51f6f587..423df8038f6ee988d008ca62784a9ab2d246a442 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -172,93 +172,7 @@ static const GDebugKey gdk_debug_keys[] = {
   { "opengl",        GDK_DEBUG_OPENGL },
   { "vulkan",        GDK_DEBUG_VULKAN }
 };
-
-static gboolean
-gdk_arg_debug_cb (const char *key, const char *value, gpointer user_data, GError **error)
-{
-  guint debug_value = g_parse_debug_string (value,
-                                            (GDebugKey *) gdk_debug_keys,
-                                            G_N_ELEMENTS (gdk_debug_keys));
-
-  if (debug_value == 0 && value != NULL && strcmp (value, "") != 0)
-    {
-      g_set_error (error,
-                   G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
-                   _("Error parsing option --gdk-debug"));
-      return FALSE;
-    }
-
-  _gdk_debug_flags |= debug_value;
-
-  return TRUE;
-}
-
-static gboolean
-gdk_arg_no_debug_cb (const char *key, const char *value, gpointer user_data, GError **error)
-{
-  guint debug_value = g_parse_debug_string (value,
-                                            (GDebugKey *) gdk_debug_keys,
-                                            G_N_ELEMENTS (gdk_debug_keys));
-
-  if (debug_value == 0 && value != NULL && strcmp (value, "") != 0)
-    {
-      g_set_error (error,
-                   G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
-                   _("Error parsing option --gdk-no-debug"));
-      return FALSE;
-    }
-
-  _gdk_debug_flags &= ~debug_value;
-
-  return TRUE;
-}
-#endif /* G_ENABLE_DEBUG */
-
-static gboolean
-gdk_arg_class_cb (const char *key, const char *value, gpointer user_data, GError **error)
-{
-  gdk_set_program_class (value);
-  gdk_progclass_overridden = TRUE;
-
-  return TRUE;
-}
-
-static gboolean
-gdk_arg_name_cb (const char *key, const char *value, gpointer user_data, GError **error)
-{
-  g_set_prgname (value);
-
-  return TRUE;
-}
-
-static const GOptionEntry gdk_args[] = {
-  { "class",        0, 0,                     G_OPTION_ARG_CALLBACK, gdk_arg_class_cb,
-    /* Description of --class=CLASS in --help output */        N_("Program class as used by the window manager"),
-    /* Placeholder in --class=CLASS in --help output */        N_("CLASS") },
-  { "name",         0, 0,                     G_OPTION_ARG_CALLBACK, gdk_arg_name_cb,
-    /* Description of --name=NAME in --help output */          N_("Program name as used by the window manager"),
-    /* Placeholder in --name=NAME in --help output */          N_("NAME") },
-#ifndef G_OS_WIN32
-  { "display",      0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,   &_gdk_display_name,
-    /* Description of --display=DISPLAY in --help output */    N_("X display to use"),
-    /* Placeholder in --display=DISPLAY in --help output */    N_("DISPLAY") },
 #endif
-#ifdef G_ENABLE_DEBUG
-  { "gdk-debug",    0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_debug_cb,  
-    /* Description of --gdk-debug=FLAGS in --help output */    N_("GDK debugging flags to set"),
-    /* Placeholder in --gdk-debug=FLAGS in --help output */    N_("FLAGS") },
-  { "gdk-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_no_debug_cb, 
-    /* Description of --gdk-no-debug=FLAGS in --help output */ N_("GDK debugging flags to unset"),
-    /* Placeholder in --gdk-no-debug=FLAGS in --help output */ N_("FLAGS") },
-#endif 
-  { NULL }
-};
-
-void
-gdk_add_option_entries (GOptionGroup *group)
-{
-  g_option_group_add_entries (group, gdk_args);
-}
 
 static gpointer
 register_resources (gpointer dummy G_GNUC_UNUSED)
@@ -327,53 +241,6 @@ gdk_pre_parse (void)
     }
 }
 
-/**
- * gdk_parse_args:
- * @argc: the number of command line arguments.
- * @argv: (inout) (array length=argc): the array of command line arguments.
- * 
- * Parse command line arguments, and store for future
- * use by calls to gdk_display_open().
- *
- * Any arguments used by GDK are removed from the array and @argc and @argv are
- * updated accordingly.
- *
- * You shouldn’t call this function explicitly if you are using
- * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
- *
- * Since: 2.2
- **/
-void
-gdk_parse_args (int    *argc,
-                char ***argv)
-{
-  GOptionContext *option_context;
-  GOptionGroup *option_group;
-  GError *error = NULL;
-
-  if (gdk_initialized)
-    return;
-
-  gdk_pre_parse ();
-
-  option_context = g_option_context_new (NULL);
-  g_option_context_set_ignore_unknown_options (option_context, TRUE);
-  g_option_context_set_help_enabled (option_context, FALSE);
-  option_group = g_option_group_new (NULL, NULL, NULL, NULL, NULL);
-  g_option_context_set_main_group (option_context, option_group);
-
-  g_option_group_add_entries (option_group, gdk_args);
-
-  if (!g_option_context_parse (option_context, argc, argv, &error))
-    {
-      g_warning ("%s", error->message);
-      g_error_free (error);
-    }
-  g_option_context_free (option_context);
-
-  GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
-}
-
 /**
  * gdk_get_display_arg_name:
  *
@@ -423,60 +290,6 @@ gdk_display_open_default (void)
   return display;
 }
 
-/**
- * gdk_init_check:
- * @argc: (inout): the number of command line arguments.
- * @argv: (array length=argc) (inout): the array of command line arguments.
- *
- * Initializes the GDK library and connects to the windowing system,
- * returning %TRUE on success.
- *
- * Any arguments used by GDK are removed from the array and @argc and @argv
- * are updated accordingly.
- *
- * GTK+ initializes GDK in gtk_init() and so this function is not usually
- * needed by GTK+ applications.
- *
- * Returns: %TRUE if initialization succeeded.
- */
-gboolean
-gdk_init_check (int    *argc,
-                char ***argv)
-{
-  gdk_parse_args (argc, argv);
-
-  return gdk_display_open_default () != NULL;
-}
-
-
-/**
- * gdk_init:
- * @argc: (inout): the number of command line arguments.
- * @argv: (array length=argc) (inout): the array of command line arguments.
- *
- * Initializes the GDK library and connects to the windowing system.
- * If initialization fails, a warning message is output and the application
- * terminates with a call to `exit(1)`.
- *
- * Any arguments used by GDK are removed from the array and @argc and @argv
- * are updated accordingly.
- *
- * GTK+ initializes GDK in gtk_init() and so this function is not usually
- * needed by GTK+ applications.
- */
-void
-gdk_init (int *argc, char ***argv)
-{
-  if (!gdk_init_check (argc, argv))
-    {
-      const char *display_name = gdk_get_display_arg_name ();
-      g_warning ("cannot open display: %s", display_name ? display_name : "");
-      exit(1);
-    }
-}
-
-
-
 /**
  * SECTION:threads
  * @Short_description: Functions for using GDK in multi-threaded programs
index 2e1061dd9998923c953695a281735202a791249c..b1e9c13f1379bbe391432598b687271c16b9e37f 100644 (file)
@@ -40,16 +40,6 @@ G_BEGIN_DECLS
 
 #define GDK_PRIORITY_EVENTS (G_PRIORITY_DEFAULT)
 
-GDK_AVAILABLE_IN_ALL
-void                  gdk_parse_args                      (gint           *argc,
-                                                           gchar        ***argv);
-GDK_AVAILABLE_IN_ALL
-void                  gdk_init                            (gint           *argc,
-                                                           gchar        ***argv);
-GDK_AVAILABLE_IN_ALL
-gboolean              gdk_init_check                      (gint           *argc,
-                                                           gchar        ***argv);
-
 GDK_AVAILABLE_IN_ALL
 const gchar *         gdk_get_program_class               (void);
 GDK_AVAILABLE_IN_ALL